POV-Ray : Newsgroups : povray.programming : array question : Re: array question Server Time
5 Jul 2024 14:03:28 EDT (-0400)
  Re: array question  
From: Warp
Date: 20 Sep 2003 13:59:07
Message: <3f6c956b@news.povray.org>
Ricky Reusser <ple### [at] emailcom> wrote:
> All of the variables are correctly defined as int's and it does the same
> thing if I type float u[100][100][100];

  Actually according to the standard the dimensions of an array must be
compile-time constants (even though some compilers support allocating
such arrays at runtime), but I believe this is besides the point in this
case.

> or with other data types.  It works
> just fine with smaller numbers, but once I get to somewhere in the area of
> 30-40 ^3, I just get an error.  I thought there might be a limit on how
> much memory you can allocate at once

  This depends a lot on the compiler (and sometimes the OS) you are using.
There's nothing in the C standard which would limit the size of an array.

  In some systems compilers allocate a fixed amount of space for certain
things (such as the stack). I wonder if the compiler you are using has
some odd type of limit for statically allocated arrays.

  This simple code worked ok for me (gcc 3.3.1 in a Sparc Solaris system).
Does it cause a segmentation fault for you?

-------8<------------8<-----------8<-------------8<-----------8<--------
#include <iostream>

int main()
{   
    float u[100][100][100];
    u[50][60][70] = 5;
    std::cout << u[50][60][70] << std::endl;
}
-------8<------------8<-----------8<-------------8<-----------8<--------

-- 
plane{-x+y,-1pigment{bozo color_map{[0rgb x][1rgb x+y]}turbulence 1}}
sphere{0,2pigment{rgbt 1}interior{media{emission 1density{spherical
density_map{[0rgb 0][.5rgb<1,.5>][1rgb 1]}turbulence.9}}}scale
<1,1,3>hollow}text{ttf"timrom""Warp".1,0translate<-1,-.1,2>}//  - Warp -


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.